package com.mes.basicdata.service;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.data.provider.Page;
import com.mes.basicdata.dao.iface.IOperationResourceDao;
import com.mes.basicdata.domain.OperationResource;
import com.mes.basicdata.domain.Part;
import com.mes.common.service.BasicService;
@Service
public class OperationResourceService extends BasicService<OperationResource>{
	@Autowired 
	private IOperationResourceDao operationResourceDao;
	
	@DataProvider
	public List<OperationResource> getOperationResourceListByOperationUid(String operationUid) throws Exception{
		//return operationResourceDao.getOperationResourceListByOperationUid(operationUid);
		
		List<OperationResource> list = operationResourceDao.getOperationResourceListByOperationUid(operationUid);
		return list;
	}
	
	@DataProvider
    public void getOperationResourceByConditions(Page<Part> page, Map<String, Object> params){
    	if (params != null && !params.equals("") ){
    		try {
    			operationResourceDao.getOperationResourceByConditions(page, params);
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}else {
			try {
				this.getAll(page);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
    }
	
	@DataProvider
	public Integer getResourceCount(){
		return operationResourceDao.getResourceCount();
	}
}
